package org.gruposp2p.dnie.client.ui.panel;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.History;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget;

public class HeaderPanel extends Composite {

	private static PanelEncabezadoUiBinder uiBinder = GWT
			.create(PanelEncabezadoUiBinder.class);

	interface PanelEncabezadoUiBinder extends UiBinder<Widget, HeaderPanel> {}

	@UiField Button acceptButton;
	@UiField TextBox searchTextBox;
	
	public HeaderPanel(String firstName) {
		initWidget(uiBinder.createAndBindUi(this));
		searchTextBox.setText("");
	}

	public HeaderPanel() {
		initWidget(uiBinder.createAndBindUi(this));
	}
	
	@UiHandler("acceptButton")
	void onClick(ClickEvent e) {
		if (!"".equals(searchTextBox.getText().trim())) 
			History.newItem("#searchPanel");
	}

}
